package com.kiln.juxingqs.dialog

import androidx.databinding.ObservableField
import androidx.fragment.app.FragmentActivity
import client.global.commlib.utils.StoreUtil
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.UserInfo
import com.kiln.juxingqs.databinding.DialogSelectpaytypeBinding
import com.tzstore.oo.dialog.BottomBindingDialog

class SelectPaytypeDialog(context: FragmentActivity) :
    BottomBindingDialog<DialogSelectpaytypeBinding>(context) {

    override fun getV(): Int {
        return R.layout.dialog_selectpaytype
    }

    val income = ObservableField<String>("0")
    val integral = ObservableField<String>("0")

    override fun postBinding() {
        binding.event = this
        StoreUtil.getBean<UserInfo>(context)?.let {
            income.set("${it.income}")
            integral.set("${it.integral}")
        }
    }

    var one: ((type: Int, txt: String) -> Unit)? = null

    fun oneType() {
        cancel()
        one?.invoke(2, "余额支付(余额:${income.get()},积分:${integral.get()})")
    }

    fun twoTYpe() {
        cancel()
        one?.invoke(1, "现金支付")
    }
}